package view;

import java.awt.*;
import java.util.*;

import model.Bear;
import model.FieldStats;
import model.Fox;
import model.Hunter;
import model.Rabbit;
import model.Values;

/**
 * A class for setting colors in the views.
 * 
 * @author Martin Kromkamp and Albert-Jan Boer.
 * @version 2009.01.28
 */
public abstract class View {
	// Color used for objects that have no defined color.
    private static final Color UNKNOWN_COLOR = Color.gray;
    // A map for storing colors for participants in the simulation
    public HashMap<Class, Color> colors;
    // A statistics object computing and storing simulation information
    protected FieldStats stats;
    // Value
    protected Values value;
    
    /**
     * The constructor of View.
     */
    public View()
    {
    	stats = new FieldStats();
    	colors = new HashMap<Class, Color>();
    	
    	setColor(Rabbit.class, Color.orange);
        setColor(Fox.class, Color.blue);
        setColor(Hunter.class, Color.gray);
        setColor(Bear.class, new Color(150,75,0)); // brown
    }
    
    /**
     * Define a color to be used for a given class of animal.
     * @param animalClass The animal's Class object.
     * @param color The color to be used for the given class.
     */
    public void setColor(Class animalClass, Color color)
    {
        colors.put(animalClass, color);
    }
    
    /**
     * @return The color to be used for a given class of animal.
     */
    protected Color getColor(Class animalClass)
    {
        Color col = colors.get(animalClass);
        if(col == null) {
            // no color defined for this class
            return UNKNOWN_COLOR;
        }
        else {
            return col;
        }
    } 
}

